using octalforty.BizFramework.Core;

using octalforty.Waffle.ObjectModel.Business.Collections;
using octalforty.Waffle.ObjectModel.Business.Objects;

using Spring.Data.NHibernate.Generic.Support;

using Spring.Transaction;
using Spring.Transaction.Interceptor;

namespace octalforty.Waffle.ComponentModel.Managers.Impl
{
    /// <summary>
    /// <see cref="HibernateDaoSupport"/>-based implementation of the <see cref="IForumManagerService"/>.
    /// </summary>
    public class HibernateForumManagerService : HibernateDaoSupport, IForumManagerService
    {
        /// <summary>
        /// Initializes a new instance of <see cref="HibernateForumManagerService"/> class.
        /// </summary>
        public HibernateForumManagerService()
        {
        }

        #region IForumManagerService Members
        /// <summary>
        /// Returns a collection of persistent instances of <see cref="Forum"/> objects,
        /// which represent all forums, ordered by <see cref="IBusinessObjectWithName.Name"/>.
        /// </summary>
        /// <returns></returns>
        [Transaction(TransactionPropagation.Supports)]
        public ForumCollection GetForums()
        {
            return new ForumCollection(HibernateTemplate.FindByNamedQuery<Forum>("GetForums"));
        }
        #endregion
    }
}
